#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;
int n;
int a[N], ans = INT_MAX;
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] ^= a[i - 1];
    }
    if (n > 60) cout << "1";
    else {
        for (int i = 1; i <= n; i++)
            for (int j = i; j <= n; j++)
                for (int k = j + 1; k <= n; k++)
                    if ((a[j] ^ a[i - 1]) > (a[k] ^ a[j]))
                        ans = min(ans, k - i - 1);
        if (ans == INT_MAX) printf("-1");
        else printf("%d", ans);
    }
    return 0;
}
